Optimal. Leaf size=65 \[ \frac {a b \tanh ^{-1}\left (\frac {a \cos (x)-b \sin (x)}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}}-\frac {b \cos (x)}{a^2+b^2}+\frac {a \sin (x)}{a^2+b^2} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.06, antiderivative size = 65, normalized size of antiderivative = 1.00, number of steps
used = 6, number of rules used = 6, integrand size = 11, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.546, Rules used = {3599, 3188,
2717, 2718, 3153, 212} \begin {gather*} \frac {a \sin (x)}{a^2+b^2}-\frac {b \cos (x)}{a^2+b^2}+\frac {a b \tanh ^{-1}\left (\frac {a \cos (x)-b \sin (x)}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 212
Rule 2717
Rule 2718
Rule 3153
Rule 3188
Rule 3599
Rubi steps
\begin {align*} \int \frac {\cos (x)}{a+b \cot (x)} \, dx &=-\int \frac {\cos (x) \sin (x)}{-b \cos (x)-a \sin (x)} \, dx\\ &=\frac {a \int \cos (x) \, dx}{a^2+b^2}+\frac {b \int \sin (x) \, dx}{a^2+b^2}+\frac {(a b) \int \frac {1}{-b \cos (x)-a \sin (x)} \, dx}{a^2+b^2}\\ &=-\frac {b \cos (x)}{a^2+b^2}+\frac {a \sin (x)}{a^2+b^2}-\frac {(a b) \text {Subst}\left (\int \frac {1}{a^2+b^2-x^2} \, dx,x,-a \cos (x)+b \sin (x)\right )}{a^2+b^2}\\ &=\frac {a b \tanh ^{-1}\left (\frac {a \cos (x)-b \sin (x)}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}}-\frac {b \cos (x)}{a^2+b^2}+\frac {a \sin (x)}{a^2+b^2}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.21, size = 61, normalized size = 0.94 \begin {gather*} -\frac {2 a b \tanh ^{-1}\left (\frac {-a+b \tan \left (\frac {x}{2}\right )}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}}+\frac {-b \cos (x)+a \sin (x)}{a^2+b^2} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.29, size = 81, normalized size = 1.25
method | result | size |
default | \(-\frac {2 \left (-a \tan \left (\frac {x}{2}\right )+b \right )}{\left (a^{2}+b^{2}\right ) \left (1+\tan ^{2}\left (\frac {x}{2}\right )\right )}+\frac {4 a b \arctanh \left (\frac {-2 b \tan \left (\frac {x}{2}\right )+2 a}{2 \sqrt {a^{2}+b^{2}}}\right )}{\left (2 a^{2}+2 b^{2}\right ) \sqrt {a^{2}+b^{2}}}\) | \(81\) |
risch | \(-\frac {i {\mathrm e}^{i x}}{2 \left (i b +a \right )}+\frac {i {\mathrm e}^{-i x}}{-2 i b +2 a}+\frac {b a \ln \left ({\mathrm e}^{i x}-\frac {i a^{2} b +i b^{3}-a^{3}-a \,b^{2}}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}}}\right )}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}}}-\frac {b a \ln \left ({\mathrm e}^{i x}+\frac {i a^{2} b +i b^{3}-a^{3}-a \,b^{2}}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}}}\right )}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}}}\) | \(144\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.51, size = 105, normalized size = 1.62 \begin {gather*} \frac {a b \log \left (\frac {a - \frac {b \sin \left (x\right )}{\cos \left (x\right ) + 1} + \sqrt {a^{2} + b^{2}}}{a - \frac {b \sin \left (x\right )}{\cos \left (x\right ) + 1} - \sqrt {a^{2} + b^{2}}}\right )}{{\left (a^{2} + b^{2}\right )}^{\frac {3}{2}}} - \frac {2 \, {\left (b - \frac {a \sin \left (x\right )}{\cos \left (x\right ) + 1}\right )}}{a^{2} + b^{2} + \frac {{\left (a^{2} + b^{2}\right )} \sin \left (x\right )^{2}}{{\left (\cos \left (x\right ) + 1\right )}^{2}}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 144 vs.
\(2 (61) = 122\).
time = 4.09, size = 144, normalized size = 2.22 \begin {gather*} \frac {\sqrt {a^{2} + b^{2}} a b \log \left (\frac {2 \, a b \cos \left (x\right ) \sin \left (x\right ) - {\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} - a^{2} - 2 \, b^{2} - 2 \, \sqrt {a^{2} + b^{2}} {\left (a \cos \left (x\right ) - b \sin \left (x\right )\right )}}{2 \, a b \cos \left (x\right ) \sin \left (x\right ) - {\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} + a^{2}}\right ) - 2 \, {\left (a^{2} b + b^{3}\right )} \cos \left (x\right ) + 2 \, {\left (a^{3} + a b^{2}\right )} \sin \left (x\right )}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {\cos {\left (x \right )}}{a + b \cot {\left (x \right )}}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.44, size = 94, normalized size = 1.45 \begin {gather*} \frac {a b \log \left (\frac {{\left | 2 \, b \tan \left (\frac {1}{2} \, x\right ) - 2 \, a - 2 \, \sqrt {a^{2} + b^{2}} \right |}}{{\left | 2 \, b \tan \left (\frac {1}{2} \, x\right ) - 2 \, a + 2 \, \sqrt {a^{2} + b^{2}} \right |}}\right )}{{\left (a^{2} + b^{2}\right )}^{\frac {3}{2}}} + \frac {2 \, {\left (a \tan \left (\frac {1}{2} \, x\right ) - b\right )}}{{\left (a^{2} + b^{2}\right )} {\left (\tan \left (\frac {1}{2} \, x\right )^{2} + 1\right )}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 0.38, size = 93, normalized size = 1.43 \begin {gather*} \frac {2\,a\,b\,\mathrm {atanh}\left (\frac {2\,a\,b^2+2\,a^3-2\,b\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (a^2+b^2\right )}{2\,{\left (a^2+b^2\right )}^{3/2}}\right )}{{\left (a^2+b^2\right )}^{3/2}}-\frac {\frac {2\,b}{a^2+b^2}-\frac {2\,a\,\mathrm {tan}\left (\frac {x}{2}\right )}{a^2+b^2}}{{\mathrm {tan}\left (\frac {x}{2}\right )}^2+1} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________